// app.js
App({
  onLaunch() {
    this.initAudeo();
    // 在 app.js 中全局获取一次系统和胶囊信息
    // 获取系统信息
    wx.getSystemInfo({success: res => {this.globalData.system = res}})
    // 获取胶囊信息
    this.globalData.capsule = wx.getMenuButtonBoundingClientRect()
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  globalData:{system: '',capsule: '',
    userInfo1: null,
    innerAudioContext1: "",
    audioSrc1: "https://ruizhihui-hefei.oss-cn-shanghai.aliyuncs.com/%E9%94%90%E6%99%BA%E6%B1%87/%E5%B9%B4%E4%BC%9A%E6%8A%BD%E5%A5%96%E9%A1%B9%E7%9B%AE/%E5%B9%B4%E4%BC%9A%E9%9F%B3%E4%B9%90.mp3", // 背景音频地址
    userInfo2: null,
    innerAudioContext2: "",
    audioSrc2: "https://pic.ibaotu.com/18/00/49/92s888piCTt8.mp3", // 抽奖音频地址
    userInfo3: null,
    innerAudioContext3: "",
    audioSrc3: "https://pic.ibaotu.com/00/61/78/827888piC54a.mp3", // 打开红包音频地址
  },
    // 初始化音频信息
    initAudeo() {
      this.globalData.innerAudioContext1 = wx.createInnerAudioContext();
      this.globalData.innerAudioContext1.autoplay = true;
      this.globalData.innerAudioContext1.src = this.globalData.audioSrc1;
      this.globalData.innerAudioContext1.loop = true;
    },
    // 播放事件
    bgPlay() {
      this.globalData.innerAudioContext1.play();
    },
    // 暂停事件
    bgPause() {
      this.globalData.innerAudioContext1.pause();
    },
    // 初始化音频信息
    initAudeo2() {
      this.globalData.innerAudioContext2 = wx.createInnerAudioContext();
      this.globalData.innerAudioContext2.autoplay = true;
      this.globalData.innerAudioContext2.src = this.globalData.audioSrc2;
      this.globalData.innerAudioContext2.loop = true;
    },
    // 播放事件
    audioPlay() {
      this.globalData.innerAudioContext2.play();
    },
    // 暂停事件
    audioPause() {
      this.globalData.innerAudioContext2.pause();
    },
    // 初始化音频信息
    initAudeo3() {
      this.globalData.innerAudioContext3 = wx.createInnerAudioContext();
      this.globalData.innerAudioContext3.autoplay = true;
      this.globalData.innerAudioContext3.src = this.globalData.audioSrc3;
      this.globalData.innerAudioContext3.loop = true;
    },
    // 播放事件
    openPlay() {
      this.globalData.innerAudioContext3.play();
    },
    // 暂停事件
    openPause() {
      this.globalData.innerAudioContext3.pause();
    },

})
